﻿using Supermarket;
using System;
using System.Data;
using System.Drawing;
using System.Net;
using System.Net.Mail;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace XLSupermarket.Financial.The_statistical_summary
{
    public partial class The_statistical_summaryForm : Form
    {
        public The_statistical_summaryForm()
        {
            InitializeComponent();
        }

        private void The_statistical_summaryForm_Load(object sender, EventArgs e)
        {

            this.comboBox3.SelectedIndex = 0;//设置该下拉框默认选中第一项。

            panel1.Hide();

            this.comboBox2.SelectedIndex = 0;
            this.comboBox5.SelectedIndex = 0;

            int month = int.Parse(DateTime.Now.Month.ToString());
            this.comboBox1.SelectedIndex = month - 1;

            string year = DateTime.Now.Year.ToString();
            this.textBox1.Text = year;

            Clearchart();
            int day = Day();
            Series s1 = new Series("利润");
            for (int i = 1; i <= day; i++)
            {
                string days = Days(i);

                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                double sum1 = Sum(i, sql1, 8);

                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                double sum = Sum(i, sql, 4);

                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                double sum2 = Sum(i, sql2, 4);

                double sum3 = sum + sum2;

                double sum4 = sum1 - sum3;

                s1.Points.AddXY(i, sum4);
            }
            this.chart1.Series.Add(s1);
            this.chart1.Series[0].ChartType = SeriesChartType.Line;
            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线


        }

        /// <summary>
        /// 查询按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            Clearchart();
            if (this.comboBox2.Text == "支出")
            {
                panel1.Show();
                this.comboBox4.SelectedIndex = 0;//设置该下拉框默认选中第一项。
                if (this.comboBox4.Text == "商品支出")
                {
                    if (this.comboBox3.Text == "折线图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);
                                s1.Points.AddXY(i, sum);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                s1.Points.AddXY(i, (sum1/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12) 
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                    if (this.comboBox3.Text == "柱状图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);
                                s1.Points.AddXY(i, sum);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                s1.Points.AddXY(i, (sum1/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("商品支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12)
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                }
                if (this.comboBox4.Text == "薪资支出")
                {
                    if (this.comboBox3.Text == "折线图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum = Sum(i, sql, 4);
                                s1.Points.AddXY(i, sum);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                s1.Points.AddXY(i, (sum1/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12)
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                    if (this.comboBox3.Text == "柱状图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum = Sum(i, sql, 4);
                                s1.Points.AddXY(i, sum);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                s1.Points.AddXY(i, (sum1/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("薪资支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql, 4);
                                    sum1 += sum2;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12)
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                }
                if (this.comboBox4.Text == "总支出")
                {
                    if (this.comboBox3.Text == "折线图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;
                                s1.Points.AddXY(i, sum3);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum3 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum = Sum(j, sql, 4);


                                    string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql2, 4);


                                    double sum1 = sum + sum2;
                                    sum3 += sum1;
                                }
                                s1.Points.AddXY(i, (sum3/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum = Sum(i, sql, 4);

                                    string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(i, sql2, 4);

                                    double sum3 = sum + sum2;
                                    sum1 += sum3;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12)
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Line;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                    if (this.comboBox3.Text == "柱状图")
                    {
                        if (this.comboBox5.Text == "月份")
                        {
                            int day = Day();
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= day; i++)
                            {
                                string days = Days(i);
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;
                                s1.Points.AddXY(i, sum3);
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "年份")
                        {
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum3 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum = Sum(j, sql, 4);


                                    string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(j, sql2, 4);


                                    double sum1 = sum + sum2;
                                    sum3 += sum1;
                                }
                                s1.Points.AddXY(i, (sum3/1000));
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                        if (this.comboBox5.Text == "季度")
                        {
                            double sumjidu = 0;
                            int num = 0;
                            Series s1 = new Series("总支出");
                            for (int i = 1; i <= 12; i++)
                            {
                                int day = 0;
                                switch (i)
                                {
                                    case 1:
                                    case 3:
                                    case 5:
                                    case 7:
                                    case 8:
                                    case 10:
                                    case 12:
                                        day = 31;
                                        break;
                                    case 4:
                                    case 6:
                                    case 9:
                                    case 11:
                                        day = 30;
                                        break;
                                    case 2:
                                        if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                        {
                                            day = 29;
                                        }
                                        else
                                        {
                                            day = 28;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                double sum1 = 0;
                                for (int j = 1; j <= day; j++)
                                {
                                    string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                    string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                    double sum = Sum(i, sql, 4);

                                    string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                    double sum2 = Sum(i, sql2, 4);

                                    double sum3 = sum + sum2;
                                    sum1 += sum3;
                                }
                                sumjidu += sum1;
                                if (i == 3 || i == 6 || i == 9 || i == 12)
                                {
                                    num++;
                                    s1.Points.AddXY(num, (sumjidu/1000));
                                    sumjidu = 0;
                                }
                            }
                            this.chart1.Series.Add(s1);
                            this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                            this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                            this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                            this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                            this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                        }
                    }
                }
            }
            if (this.comboBox2.Text == "收入")
            {
                panel1.Hide();
                if (this.comboBox3.Text == "折线图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        int day = Day();
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                            double sum = Sum(i, sql, 0);
                            s1.Points.AddXY(i, sum);
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            s1.Points.AddXY(i, (sum1/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        double sumjidu = 0;
                        int num = 0;
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            sumjidu += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num++;
                                s1.Points.AddXY(num, (sumjidu/1000));
                                sumjidu = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                }
                if (this.comboBox3.Text == "柱状图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        int day = Day();
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                            double sum = Sum(i, sql, 0);
                            s1.Points.AddXY(i, sum);
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            s1.Points.AddXY(i, (sum1/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        double sumjidu = 0;
                        int num = 0;
                        Series s1 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            sumjidu += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num++;
                                s1.Points.AddXY(num, (sumjidu/1000));
                                sumjidu = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                }
            }
            if(this.comboBox2.Text == "利润")
            {
                panel1.Hide();
                if (this.comboBox3.Text == "折线图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        int day = Day();
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);

                            string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                            double sum1 = Sum(i, sql1, 8);

                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;

                            double sum4 = sum1 - sum3;

                            s1.Points.AddXY(i, sum4);
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            s1.Points.AddXY(i, (sum5/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        double sumjidu = 0;
                        int num = 0;
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;
                                
                                sum5 += sum4;
                            }
                            sumjidu += sum5;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num++;
                                s1.Points.AddXY(num, (sumjidu/1000));
                                sumjidu = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                }
                if (this.comboBox3.Text == "柱状图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        int day = Day();
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);

                            string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                            double sum1 = Sum(i, sql1, 8);

                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;

                            double sum4 = sum1 - sum3;

                            s1.Points.AddXY(i, (sum4/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            s1.Points.AddXY(i, (sum5/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        double sumjidu = 0;
                        int num = 0;
                        Series s1 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            sumjidu += sum5;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num++;
                                s1.Points.AddXY(num, (sumjidu/1000));
                                sumjidu = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线
                    }
                }
            }
            if (this.comboBox2.Text == "三表综合")
            {
                panel1.Hide();
                if (this.comboBox3.Text =="折线图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        //总支出折线
                        int day = Day();
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;
                            s1.Points.AddXY(i, sum3);
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线



                        //收入折线
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                            double sum = Sum(i, sql, 0);
                            s2.Points.AddXY(i, sum);
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Line;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润折线
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);

                            string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                            double sum1 = Sum(i, sql1, 8);

                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;

                            double sum4 = sum1 - sum3;

                            s3.Points.AddXY(i, sum4);
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Line;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值

                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        ////总支出
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum3 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(j, sql, 4);


                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(j, sql2, 4);


                                double sum1 = sum + sum2;
                                sum3 += sum1;
                            }
                            s1.Points.AddXY(i, (sum3/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线


                        //收入
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            s2.Points.AddXY(i, (sum1/1000));
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Line;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            s3.Points.AddXY(i, (sum5/1000));
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Line;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        //总支出
                        double sumjidu1 = 0;
                        int num1 = 0;
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;
                                sum1 += sum3;
                            }
                            sumjidu1 += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num1++;
                                s1.Points.AddXY(num1, (sumjidu1/1000));
                                sumjidu1 = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Line;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线


                        //收入
                        double sumjidu2 = 0;
                        int num2 = 0;
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            sumjidu2 += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num2++;
                                s2.Points.AddXY(num2, (sumjidu2 / 1000));
                                sumjidu2 = 0;
                            }
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Line;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润
                        double sumjidu3 = 0;
                        int num3 = 0;
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            sumjidu3 += sum5;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num3++;
                                s3.Points.AddXY(num3, (sumjidu3 / 1000));
                                sumjidu3 = 0;
                            }
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Line;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值

                    }
                }
                if (this.comboBox3.Text == "柱状图")
                {
                    if (this.comboBox5.Text == "月份")
                    {
                        //总支出折线
                        int day = Day();
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;
                            s1.Points.AddXY(i, sum3);
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/天";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线



                        //收入折线
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);
                            string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                            double sum = Sum(i, sql, 0);
                            s2.Points.AddXY(i, sum);
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润折线
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= day; i++)
                        {
                            string days = Days(i);

                            string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                            double sum1 = Sum(i, sql1, 8);

                            string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                            double sum = Sum(i, sql, 4);

                            string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                            double sum2 = Sum(i, sql2, 4);

                            double sum3 = sum + sum2;

                            double sum4 = sum1 - sum3;

                            s3.Points.AddXY(i, sum4);
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值

                    }
                    if (this.comboBox5.Text == "年份")
                    {
                        ////总支出
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum3 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(j, sql, 4);


                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(j, sql2, 4);


                                double sum1 = sum + sum2;
                                sum3 += sum1;
                            }
                            s1.Points.AddXY(i, (sum3/1000));
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/月";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线


                        //收入
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            s2.Points.AddXY(i, (sum1/1000));
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            s3.Points.AddXY(i, (sum5/1000));
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值
                    }
                    if (this.comboBox5.Text == "季度")
                    {
                        //总支出
                        double sumjidu1 = 0;
                        int num1 = 0;
                        Series s1 = new Series("总支出");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;
                                sum1 += sum3;
                            }
                            sumjidu1 += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num1++;
                                s1.Points.AddXY(num1, (sumjidu1/1000));
                                sumjidu1 = 0;
                            }
                        }
                        this.chart1.Series.Add(s1);
                        this.chart1.Series[0].ChartType = SeriesChartType.Bar;
                        this.chart1.ChartAreas["ChartArea1"].AxisX.Title = "时间/季度";//X轴标题
                        this.chart1.ChartAreas["ChartArea1"].AxisY.Title = "金额/千元";//Y轴标题
                        this.chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
                        this.chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不显示竖着的分割线


                        //收入
                        double sumjidu2 = 0;
                        int num2 = 0;
                        Series s2 = new Series("收入");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum1 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql = string.Format("select Receivables from Sales_Order where Time_Of_Sale = '{0}'", days);
                                double sum2 = Sum(j, sql, 0);
                                sum1 += sum2;
                            }
                            sumjidu2 += sum1;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num2++;
                                s2.Points.AddXY(num2, (sumjidu2/1000));
                                sumjidu2 = 0;
                            }
                        }
                        this.chart1.Series.Add(s2);
                        this.chart1.Series[1].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[1].IsValueShownAsLabel = true;//显示坐标值


                        //利润
                        double sumjidu3 = 0;
                        int num3 = 0;
                        Series s3 = new Series("利润");
                        for (int i = 1; i <= 12; i++)
                        {
                            int day = 0;
                            switch (i)
                            {
                                case 1:
                                case 3:
                                case 5:
                                case 7:
                                case 8:
                                case 10:
                                case 12:
                                    day = 31;
                                    break;
                                case 4:
                                case 6:
                                case 9:
                                case 11:
                                    day = 30;
                                    break;
                                case 2:
                                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                                    {
                                        day = 29;
                                    }
                                    else
                                    {
                                        day = 28;
                                    }
                                    break;
                                default:
                                    break;
                            }
                            double sum5 = 0;
                            for (int j = 1; j <= day; j++)
                            {
                                string days = this.textBox1.Text.ToString() + "-" + i.ToString() + "-" + j.ToString();
                                string sql1 = string.Format("select s.Order_Number 订单编号,Time_Of_Sale 销售日期,ep.EP_Name 收银员,VIP_ID 会员编号,Trade_Name 商品名称,od.Number 数量,od.Price 售价,od.Bar_code 商品条形码,od.Price*od.Number-gw.Purchase_price*od.Number 利润,gw.Other 备注 from Sales_Order s ,EP_information ep, Goods_Warehousing gw,Order_Details od where s.EP_ID = ep.EP_ID and s.Order_Number = od.Order_Number and od.Bar_code = gw.Bar_code and Time_Of_Sale = '{0}'", days);
                                double sum1 = Sum(i, sql1, 8);

                                string sql = string.Format("select Trade_Name 商品名称,Bar_code 商品条形码,Purchase_price 商品进价,Number 进货数量,Purchase_price*Number 商品总支出,Purchase_time 进货时间,Other 备注 from Goods_Warehousing where Purchase_time = '{0}'", days);
                                double sum = Sum(i, sql, 4);

                                string sql2 = string.Format("select ei.EP_Name 员工姓名,se.Base_Pay 基本薪资,se.Bonus 奖金,se.Commission 提成,se.Base_Pay+se.Bonus+se.Commission 薪资总支出,se.Date_Of_issue 发放日期,se.Other 备注 from EP_Salary se, EP_information ei where se.EP_ID = ei.EP_ID and se.Date_Of_issue = '{0}'", days);
                                double sum2 = Sum(i, sql2, 4);

                                double sum3 = sum + sum2;

                                double sum4 = sum1 - sum3;

                                sum5 += sum4;
                            }
                            sumjidu3 += sum5;
                            if (i == 3 || i == 6 || i == 9 || i == 12)
                            {
                                num3++;
                                s3.Points.AddXY(num3, (sumjidu3/1000));
                                sumjidu3 = 0;
                            }
                        }
                        this.chart1.Series.Add(s3);
                        this.chart1.Series[2].ChartType = SeriesChartType.Bar;
                        this.chart1.Series[2].IsValueShownAsLabel = true;//显示坐标值

                    }
                }
            }
        }

        /// <summary>
        /// 获取月份的日期
        /// </summary>
        /// <returns></returns>
        public int Day() 
        {
            int day = 0;
            string mouth = comboBox1.Text.ToString();
            switch (mouth)
            {
                case "1":
                case "3":
                case "5":
                case "7":
                case "8":
                case "10":
                case "12":
                    day = 31;
                    break;
                case "4":
                case "6":
                case "9":
                case "11":
                    day = 30;
                    break;
                case "2":
                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                    {
                        day = 29;
                    }
                    else
                    {
                        day = 28;
                    }
                    break;
                default:
                    break;
            }
            return day;
        }

        /// <summary>
        /// 获取下拉框的月份
        /// </summary>
        /// <returns></returns>
        public string Mouth()
        {
            int day = 0;
            string mouth = comboBox1.Text.ToString();
            switch (mouth)
            {
                case "1":
                case "3":
                case "5":
                case "7":
                case "8":
                case "10":
                case "12":
                    day = 31;
                    break;
                case "4":
                case "6":
                case "9":
                case "11":
                    day = 30;
                    break;
                case "2":
                    if (int.Parse(this.textBox1.Text) % 4 == 0 && int.Parse(this.textBox1.Text) % 100 != 0 || int.Parse(this.textBox1.Text) % 400 == 0)
                    {
                        day = 29;
                    }
                    else
                    {
                        day = 28;
                    }
                    break;
                default:
                    break;
            }
            return mouth;
        }

        /// <summary>
        /// 组合成数据库语句中的时间
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public string Days(int i) 
        {
            int day = Day();
            string mouth = Mouth();
            string days = this.textBox1.Text.ToString() + "-" + mouth.ToString() + "-" + i.ToString();
            return days;
        }

        /// <summary>
        /// 计算总金额
        /// </summary>
        /// <param name="i"></param>
        /// <param name="sql"></param>
        /// <param name="a"></param>
        /// <returns></returns>
        public double Sum(int i,string sql,int a)
        {
            DataTable dt = DBHelper.FillData(sql);
            double sum = 0;
            for (int j = 1; j <= dt.Rows.Count; j++)
            {
                double num = double.Parse(dt.Rows[j - 1][a].ToString());
                sum += num;
            }
            return sum;
        }


        /// <summary>
        /// 清除表中数据
        /// </summary>
        public void Clearchart()
        {
            this.chart1.Series.Clear();
        }

        /// <summary>
        /// 在原有的表中继续添加数据
        /// </summary>
        public void Continuechart()
        {
            this.chart1.DataBind();
        }

        /// <summary>
        /// 清除按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button6_Click(object sender, EventArgs e)
        {
            Clearchart();
        }

        
        //保存分析图
        private void button2_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "JPEG文件|*.jpg";
            sfd.FilterIndex = 2;
            sfd.FileName = "chartimage";
            sfd.RestoreDirectory = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                chart1.SaveImage(sfd.FileName, ChartImageFormat.Jpeg);
                MessageBox.Show("保存完毕！", "提示");
            }
        }


        private void button3_Click(object sender, EventArgs e)
        {
            Financial.Wages.Send_E_mailForm sem = new Wages.Send_E_mailForm();
            sem.ShowDialog();
        }
    }
}
